import { View } from "../../../mvc/core/View";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { EffectManager } from "../../manager/EffectManager";
import { UIIconEvent } from "../uiIconBtn/UIIconEvent";
import { Cache } from "../../cache/Cache";
import { ClockManager } from "../../manager/ClockManager";
import { MsgManager } from "../../manager/MsgManager";
type int = number;
//class BlessHintIcon
    
    export  class BlessHintIcon extends View
    {
        constructor()
        {
            super();
            this.buttonMode = true;
            ToolTipsManager.register(this, null, HTMLUtil.addColor(Language.getString(69408), "#FFFFFF"));
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */createChildren(): void
        {
            this.addChild(GlobalClass.getScaleBitmap(ImagesConst.FriendBless_hintIcon));
            this._numLabel = new Object /* flash.text.TextField */();
            this._numLabel.selectable = false;
            this._numLabel.filters = [FilterConst.glowFilter];
            this._numLabel.width = 26;
            this._numLabel.height = 10;
            this._numLabel.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._numLabel.y = 12;
            addChild(this._numLabel);
            return;
        }

        /* internal  */addListeners(): void
        {
            this.addEventListener(flash.events.MouseEvent.CLICK, this.hintIcon_click);
            return;
        }

        public showIcon(arg1: int): void
        {
            this.numText = arg1;
            this.show();
            return;
        }

        public set numText(arg1: int)
        {
            this._numLabel.text = String(arg1);
            this._numLabel.setTextFormat(new GTextFormat(FontUtil.songtiName, 10, 16777215));
            return;
        }

        /* internal  */hintIcon_click(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FriendBless_ShowSendBlessList));
            this.hide();
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            if (isHide) 
            {
                if (!this._timer) 
                {
                    this._timer = new Object /* flash.utils.Timer */(this._delayTime);
                    this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
                }
                this._timer.reset();
                this._timer.start();
            }
            super.show(arg1, arg2);
            return;
        }

        public /* override */ hide(): void
        {
            if (this.parent) 
            {
                this.parent.removeChild(this);
                EffectManager.glowFilterUnReg(this);
                this.dispatchEvent(new UIIconEvent(UIIconEvent.RemoveIcon));
            }
            if (this._timer) 
            {
                this._timer.stop();
                this._timer.removeEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
                this._timer = null;
            }
            super.hide();
            return;
        }

        /* internal  */onTimerEvent(arg1: Object /* flash.events.TimerEvent */): void
        {
            this.checkTimeOut();
            return;
        }

        /* internal  */checkTimeOut(): void
        {
            var loc2=null;
            var loc1=Cache.instance.friendBless.blessQueue;
            var loc3=0;
            var loc4=loc1;
            for(loc2 of loc4) 
            {
                if (!(ClockManager.instance.nowDate.valueOf() > loc2.timeOutDt.valueOf())) 
                {
                    continue;
                }
                Cache.instance.friendBless.popBlessQueue(loc2);
                MsgManager.showRollTipsMsg(Language.getString(69409));
            }
            if (loc1.length == 0) 
            {
                this.hide();
            }
            return;
        }

        /* internal */ /* var */_numLabel: Object /* flash.text.TextField */;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_delayTime: int=1000;
    }
